<!--河南星辰软件科技有限公司
@copyright Copyright (c) 2010~2022 All rights reserved.
-->
<template>
  <div class='app-container'>
    <el-form ref="form" :model="act_re_model" :rules="rules" label-width="100px" id="mvcfm">
      <div class="form-unit">
        <span class="mvc-title-left"> 流程模型列表 </span>
      </div>
      <div>
      </div>
      <div class="el-select">
        <el-input v-model="empty" placeholder='KEY' />
      </div>
      <div class="el-select">
        <el-input v-model="empty" placeholder='名称' />
      </div>
      <el-button @click="gotoPage(''+vueparams+'')" type='primary' size="mini"><i class='fa fa-search'></i>搜索</el-button>
      <el-button @click="gotoPage(''+vueparams+'')" type='warning' size="mini"><i class='fa fa-refresh'></i>重置</el-button>
      <el-button @click="gotoPage('/oa/process/modeler/modelModal?'+vueparams+'')" type='success' size="mini"><i class='fa fa-plus'></i>创建新模型</el-button>
      <el-table :data="pageList" v-loading="loading" @selection-change="handleSelectionChange">
        <el-table-column label="#" align="center" type='selection'>
        </el-table-column>
        <el-table-column label="操作" align="center" width='100' type=''>
          <template slot-scope="scope">
            <el-dropdown trigger="click">
              <span class="el-dropdown-link">操作<i class="el-icon-arrow-down el-icon--right"></i></span>
              <el-dropdown-menu slot="dropdown">
                <el-dropdown-item>
                  <el-link @click="deploy('&modelId='+scope.row.ID_+'')">部署</el-link>
                </el-dropdown-item>
                <el-dropdown-item>
                  <el-link @click="export_('&modelId='+scope.row.ID_+'')">导出</el-link>
                </el-dropdown-item>
                <el-dropdown-item>
                  <el-link @click="remove('&modelId='+scope.row.ID_+'')">删除</el-link>
                </el-dropdown-item>
              </el-dropdown-menu>
            </el-dropdown>
          </template>
        </el-table-column>
        <el-table-column label="ID" prop="ID_">
        </el-table-column>
        <el-table-column label="KEY" prop="KEY_">
        </el-table-column>
        <el-table-column label="名称" prop="ID_">
          <template slot-scope="scope">
            <el-link @click="getModal('&modelId='+scope.row.ID_+'')" type='primary'>{{scope.row.NAME_}}</el-link>
          </template>
        </el-table-column>
        <el-table-column label="版本" prop="VERSION_">
        </el-table-column>
        <el-table-column label="创建时间" prop="CREATE_TIME_">
        </el-table-column>
        <el-table-column label="最后更新时间" prop="LAST_UPDATE_TIME_">
        </el-table-column>
        <el-table-column label="元数据" prop="META_INFO_" :show-overflow-tooltip="true">
        </el-table-column>
      </el-table>
    </el-form>
  </div>
</template>
<script>
  import request from '@/utils/request'
  export default {
    name: 'modelList',
    components: {},
    props: ['popparams'],
    data() {
      return {
        vueparams: this.getVUEParams(""),
        act_re_model: [],
        loading: true,
        pageList: [],
        pageSize: 10,
        total: null,
        elcheck: [],
        multiple: true,
        rules: {}
      }
    },
    created() {
      this.getPage(1);
    },
    updated() {},
    mounted() {},
    methods: {
      addModal(_params) {
        request({
          method: 'post',
          url: '/xcapi/VUEAction/oa/process/ModelAction/addModal?' + _params + this.vueparams,
          data: this.postData()
        }).then(data => {
          this.$router.replace("/redirect" + this.$route.fullPath);
          this.msgSuccess(data.msg);
        })
      },
      deploy(_params) {
        request({
          method: 'post',
          url: '/xcapi/VUEAction/oa/process/ModelAction/deploy?' + _params + this.vueparams,
          data: this.postData()
        }).then(data => {
          this.$router.replace("/redirect" + this.$route.fullPath);
          this.msgSuccess(data.msg);
        })
      },
      export_(_params) {
        request({
          method: 'post',
          url: '/xcapi/VUEAction/oa/process/ModelAction/export_?' + _params + this.vueparams,
          data: this.postData()
        }).then(data => {
          this.$router.replace("/redirect" + this.$route.fullPath);
          this.msgSuccess(data.msg);
        })
      },
      getModal(_params) {
        request({
          method: 'post',
          url: '/xcapi/VUEAction/oa/process/ModelAction/getModal?' + _params + this.vueparams,
          data: this.postData()
        }).then(data => {
          window.editorJson = data.model;
          mvc.popURL('/xcapi/modules/modeler/modeler.html?' + _params, 'modeler');
        })
      },
      getPage(page) {
        this.loading = true;
        request({
          method: 'get',
          url: '/xcapi/VUEAction/oa/process/ModelAction/list?' + this.vueparams,
          params: {
            pageNo: page
          }
        }).then(data => {
          this.loading = false;
          this.pageList = data.rows;
          this.total = data.total;
        })
      },
      handleSelectionChange(selection) {
        this.elcheck = selection.map(item => item["ID_"]);
        this.single = selection.length != 1;
        this.multiple = !selection.length;
      },
    },
  }
</script>
